package com.chuangke.system.dao.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.chuangke.system.entity.SysOptLog;
@Mapper
public interface SysOptLogMapper extends BaseMapper<SysOptLog>{


	@Select("select a.id,a.user,a.obj_carrier_id,a.obj_type,a.obj_id,a.obj_name,a.opt_type,a.parent_type,a.parent_id,"
			+ "a.reply_count,a.memo,a.attachment,a.appid,a.ipaddr,a.request_method,a.param,a.result,"
			+ "a.status,a.request_type,a.os,a.browser,a.dept_id,"
			+ "a.time,a.created_at from sys_opt_log a, (SELECT user,min(created_at) created_at FROM sys_opt_log ${ew.customSqlSegment} group by user) b "
			+ "${ew.customSqlSegment} and a.user=b.user and a.created_at=b.created_at order by created_at desc")
	List<SysOptLog> findReadedByCondition(@Param(Constants.WRAPPER) QueryWrapper<SysOptLog> queryWrapper);

	
	@Select("select a.id,a.user,a.obj_carrier_id,a.obj_type,a.obj_id,a.obj_name,a.opt_type,a.parent_type,a.parent_id,a.reply_count,a.memo,a.attachment,a.appid,"
			+ "a.ipaddr,a.request_method,a.param,a.result,a.status,a.request_type,a.os,a.browser,a.dept_id,a.time,a.created_at from sys_opt_log a, "
			+ "(SELECT user,min(created_at) created_at FROM sys_opt_log ${ew.customSqlSegment} group by user) b  ${ew.customSqlSegment}"
			+ "and a.user=b.user and a.created_at=b.created_at  union select a.id,a.user,a.obj_carrier_id,a.obj_type,a.obj_id,a.obj_name,"
			+ "a.opt_type,a.parent_type,a.parent_id,a.reply_count,a.memo,a.attachment,a.appid,a.ipaddr,a.request_method,a.param,a.result,a.status,"
			+ "a.request_type,a.os,a.browser,a.dept_id,a.time,a.created_at from sys_opt_log a ${ew.customSqlSegment} order by created_at desc")
	List<SysOptLog> findOneReadByCondition(@Param(Constants.WRAPPER)QueryWrapper<SysOptLog> queryWrapper);

}
